<!--头部-->
{template "header.html"}

<!--内容-->
{template "show-neirong.html"}

<script type="text/javascript">
	var comment_url = '/index.php?s={MOD_DIR}&c=comment&id={$id}';
	function dr_ajax_module_comment_{$id}(type, page) {
	    $.ajax({type: "GET", url: comment_url+"&m=index&r=1&page="+page+"&"+Math.random(), dataType:"jsonp",
	        success: function (data) {
	            if (data.code) {
	                $("#dr_module_comment_{$id}").html(data.msg);
	                $("#dr_c_select_html").html($("#dr_c_select").html());
	            } else {
	                dr_cmf_tips(0, data.msg);
	            }
	        }
	    });
	}
	function dr_bbs_comment() {
	    var loading = layer.load(2, {
	        shade: [0.3,'#fff'], //0.1透明度的白色背景
	        time: 100000000
	    });
	    $.ajax({
	        type: "POST",
	        dataType: "json",
	        url: comment_url + "&m=post",
	        data: $("#myform_comment").serialize(),
	        success: function(data) {
	            layer.close(loading);
	            dr_tips(data.code, data.msg)
	            if (data.code == 1) {
	                UE.getEditor('dr_content').setContent("");
	                dr_ajax_module_comment_{$id}(0, data.data.ctpage);
	            }
	        },
	        error: function(HttpRequest, ajaxOptions, thrownError) {
	            layer.closeAll('loading');
	            alert(HttpRequest.responseText);
	        }
	    })
	}
	// 回复评论
	function dr_wd_comment_reply(id, username) {
	    //
	    var t = $('#myform_comment').offset().top;//  获取需要跳转到标签的top值
	    $("html,body").animate({ scrollTop: t}, 500); // 动态跳转到指定位置（数值越大滚动速度越慢）
	    $('#comment_submit').html('回复@'+username);
	    comment_url = comment_url+'&rid='+id;
	    UE.getEditor('dr_content').setContent("回复@"+username, true);
	}
	function dr_zc_comment(id) {
	    $.ajax({
	        type: "GET",
	        dataType: "json",
	        url: comment_url + "&m=op&t=zc&rid=" + id,
	        data: {},
	        success: function(data) {
	            if (data.code == 1) {
	                $("#dr_comment_zc_" + id).html(data.msg)
	            } else {
	                dr_tips(data.code, data.msg)
	            }
	        }
	    })
	}
	function dr_fd_comment(id) {
	    $.ajax({
	        type: "GET",
	        dataType: "json",
	        url: comment_url + "&m=op&t=fd&rid=" + id,
	        data: {},
	        success: function(data) {
	            if (data.code == 1) {
	                $("#dr_comment_fd_" + id).html(data.msg)
	            } else {
	                dr_tips(0, data.msg)
	            }
	        }
	    })
	}
	function dr_delete_comment(id) {
	    $.ajax({
	        type: "GET",
	        dataType: "json",
	        url: comment_url + "&m=op&t=delete&rid=" + id,
	        data: {},
	        success: function(data) {
	            if (data.code == 1) {
	                dr_ajax_module_comment_{$id}(0, 1);
	                dr_tips(1, data.msg)
	            } else {
	                dr_tips(0, data.msg)
	            }
	        }
	    })
	}
	function dr_wd_comment_ok(id) {
	    var url = "/index.php?s={MOD_DIR}&c=api&m=myda&id="+id;
	    layer.open({
	        type: 2,
	        title: "设为满意答案",
	        fix:true,
	        scrollbar: false,
	        shadeClose: false,
	        shade: 0,
	        area: ['500px', '300px'],
	        btn: ['完结本帖', '返回'],
	        yes: function(index, layero){
	            var body = layer.getChildFrame('body', index);
	            // 延迟加载
	            var loading = layer.load(2, {
	                shade: [0.3,'#fff'], //0.1透明度的白色背景
	                time: 100000000
	            });
	            $.ajax({type: "POST",dataType:"json", url: url, data: $(body).find('#myform').serialize(),
	                success: function(json) {
	                    layer.close(loading);
	                    if (json.code == 1) {
	                        layer.close(index);
	                        setTimeout("window.location.reload(true)", 2000);
	                        dr_cmf_tips(1, json.msg);
	                    } else {
	                        $(body).find('#dr_row_'+json.data.field).addClass('has-error');
	                        dr_cmf_tips(0, json.msg);
	                    }
	                    return false;
	                },
	                error: function(HttpRequest, ajaxOptions, thrownError) {
	                    layer.closeAll('loading');
	                    alert(HttpRequest.responseText);
	                }
	            });
	            return false;
	        },
	        content: url+'&is_ajax=1'
	    });
	}
</script>
<!--尾部-->

{template "footer-kong.html"}